package com.desktopmng.orm;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * {Enter Class Description};
 * Copyright:   Copyright (c)
 * Company:     Zhejing Public Information Industry
 * @author:     Wang Jun
 * @version:    2.0
 *
 * Modification History:
 * Date			Author		Version		Description
 * ------------------------------------------------------------------
 * 2008-6-05	Wang Jun	2.0			Initialize Version.
 */
@Entity
@Table(name = "JFOSS2_ROLE")
public class Role extends BaseEntity {

	public Role() {		//无参构造函数，struts2调用
	}
	
	public Role(String roleName , char roleType ){
		this.roleName = roleName;
		this.roleType = (char)roleType;
	}

	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "ROLE_ID")
	@GeneratedValue(strategy = GenerationType.AUTO,generator = "SEQ_ROLE_ID")
	@SequenceGenerator(name = "SEQ_ROLE_ID",sequenceName = "SEQ_ROLE_ID")
	private Long id;

	@Column(name = "ROLE_NAME",length = 30,nullable = false,unique = true)
	private String roleName;

	@Column(name = "ROLE_DESC",length = 50)
	private String description;
	
	@Column(name = "ROLE_TYPE" ,nullable = false)
	private char roleType;
	
	
	
	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the roleName
	 */
	public String getRoleName() {
		return roleName;
	}

	/**
	 * @param roleName the roleName to set
	 */
	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the roleType
	 */
	public char getRoleType() {
		return roleType;
	}

	/**
	 * @param roleType the roleType to set
	 */
	public void setRoleType(char roleType) {
		this.roleType = roleType;
	}

	public boolean equals(Object object) {
		if (this == object)
			return true;
		if (object == null)
			return false;

		if (Role.class.isInstance(object)) {
			Role peer = (Role) object;
			if (this.getId().equals( peer.getId())) {
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

	public int hashCode() {
		StringBuffer sb = new StringBuffer();
		sb.append("Role:").append(this.getId());
		return sb.toString().hashCode();
	}
}
